//
//  KWMWebViewVC.m
//  DiDiUser
//
//  Created by kevin on 4/2/15.
//  Copyright (c) 2015 kwm. All rights reserved.
//

#import "KWMWebViewVC.h"
#import "NSString+SAMAdditions.h"
#import "KWMStringUtil.h"

@implementation KWMWebViewVC

+(NSString *)kwmTag{
    return @"WebViewVC";
}


-(void)awakeFromNib{
    [super awakeFromNib];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.detailTitle;
    [self loadData];
}

-(void) loadData{
    
    self.vIndicator.hidden = NO;
    self.wbDetail.hidden = YES;
    [self.vIndicator startAnimating];
    self.wbDetail.scalesPageToFit = YES;
    
    
    if (![self.detailPath sam_containsString:@"http://"]) {
        self.detailPath = [NSString stringWithFormat:@"%@%@",@"http://",self.detailPath];
    }
    
    NSURL *url =[NSURL URLWithString:self.detailPath];
    NSURLRequest *request =[NSURLRequest requestWithURL:url];
    [self.wbDetail loadRequest:request];
}

#pragma mark webViewDelegate

-(void)webViewDidStartLoad:(UIWebView *)webView{
    self.vIndicator.hidden = NO;
    [self.vIndicator startAnimating];
}

-(void)webViewDidFinishLoad:(UIWebView *)webView{
    [self.vIndicator stopAnimating];
    self.vIndicator.hidden = YES;
    self.wbDetail.hidden = NO;
}

@end
